import request from '@/utils/request'

// 查询活动组列表
export function listGroup(query) {
  return request({
    url: '/api/activity_group/list',
    method: 'get',
    params: query
  })
}

// 查询活动组详细
export function getGroup(id) {
  return request({
    url: '/api/activity_group/getInfo/' + id,
    method: 'get'
  })
}

// 新增活动组
export function addGroup(data, file) {
  const formData = new FormData();
  formData.append('activityGroup', JSON.stringify(data));
  if (file) {
    formData.append('file', file);
  }
  return request({
    url: '/api/activity_group/add',
    method: 'post',
    data: formData,
    headers: {
      'Content-Type': 'multipart/form-data'
    }
  });
}

// 修改活动组
export function updateGroup(data, file) {
  const formData = new FormData();
  formData.append('activityGroup', JSON.stringify(data));
  if (file) {
    formData.append('file', file);
  }
  return request({
    url: '/api/activity_group/edit',
    method: 'put',
    data: formData,
    headers: {
      'Content-Type': 'multipart/form-data'
    }
  });
}

// 删除活动组
export function delGroup(id) {
  return request({
    url: '/api/activity_group/remove/' + id,
    method: 'delete'
  })
}